home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.4 Applications 1997 August / SGI IRIX 6.4 Applications 1997 August.iso / dist / gateway.idb / usr / WebFace / Apps / Apps.hinv.cgi.z / Apps.hinv.cgi
Encoding:
Text File  |  1997-07-30  |  2.1 KB  |  88 lines

  1. #!/usr/bin/perl5
  2.  
  3. # Apps.hinv.cgi
  4. # Silicon Graphics
  5.  
  6. &generic;
  7.  
  8. sub generic {
  9.     print "Content-type: text/html\n\n";
  10.  
  11.     print "<html><head><title>Hardware Inventory</title>\n";
  12.  
  13.     print "<body bgcolor=\'decec4\' background=/apps/hinv.bg.gif>\n";
  14.  
  15.     open(IN, "/usr/OnRamp/bin/htnetwork |");
  16.     $my_name = <IN>;
  17.     $my_name = (split(/:/,$my_name))[5];
  18.     chop($my_name);
  19.     close(IN);
  20.  
  21.     $str = "Hardware inventory for <br>" .
  22.            "<font size=7><tt>$my_name</tt></font>";
  23.     print "<table width=100%>",
  24.           "<tr><th align=left><h2>$str</h2></th>\n",
  25.           "<th align=right><a href=\"/newsplash.shtml\">",
  26.           "<img height=55 width=57 border=0 src=/apps/home.gif></a>\n",
  27.           "  <a href=\"Apps.shtml\">",
  28.           "<img height=55 width=57 border=0 src=/apps/back.gif></a>",
  29.           "</tr></table>\n";
  30.  
  31.     print "<br><hr width=50% size=6><br>";
  32.  
  33.     print "<center>\n";
  34.  
  35.     print "<table width=600>\n";
  36.  
  37.     open(IN,"/sbin/hinv |");
  38.  
  39.     while(<IN>) {
  40.  
  41.         ($a,$b,$c) = split(/:/);
  42.     
  43.         $b .= $c;
  44.         if ($a ne "  Disk drive") {    
  45.             print "<tr valign=top><th align=right nowrap>$a<td>  "
  46.             . "</td><td><tt>$b</tt></td></tr>\n";
  47.         }
  48.  
  49.     }
  50.  
  51.     close(IN);    
  52.     
  53.     print "</table><p><hr width=50% size=6>";
  54.  
  55.     print "</center><h3>Disk drives:</h3><center>";
  56.  
  57.     print "<table width=600>";
  58.  
  59.     open(IN,"/usr/sbin/df |");
  60.  
  61.     $first = <IN>;
  62. #       @names = split(/\s+/, $first);
  63.  
  64.     @names = ('Filesystem','Size (MB)','Used (MB)','Mounted on');
  65.  
  66.         print "<tr>\n";
  67.         foreach (@names) { print "<th align=left>$_\n"; }
  68.         print "</tr>\n";
  69.  
  70.     while(<IN>) {
  71.  
  72.         ($fs,$dum,$bl,$us,$av,$pct,$where) = split(/\s+/);
  73.  
  74.         # df info is in 512-byte blocks
  75.         $bl /= 2048; $bl =~ s/(\d*\.\d).*/$1/g;
  76.         $us /= 2048; $us =~ s/(\d*\.\d).*/$1/g;
  77.  
  78.         print "<tr>\n";
  79.         print "<td><tt>$fs</tt></td><td><tt>$bl</tt></td>\n";
  80.         print "<td><tt>$us</tt></td><td><tt>$where</tt></td>";
  81.         print "</tr>\n";
  82.     }    
  83.  
  84.     close(IN);
  85.  
  86.     print "</table></center></body></html>\n";
  87. }
  88.